import React, { useState, useEffect } from 'react'
import store from '../redux/store'
export default function Count() {
  const [x, setX] = useState(0)
  useEffect(() => {
    store.subscribe(() => {
      setX((x) => {
        return x + 1
      })
    })
  }, [])
  return (
    <>
      <p>{store.getState().count}</p>
      <button
        onClick={() => {
          store.dispatch({ type: 'add', num: 6 })
        }}
      >
        +
      </button>
    </>
  )
}
